<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    response.setHeader("cache-control","public");
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>
<!-- 题库列表,创建题库入口 -->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <title>在线考试系统</title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/font/font-awesome.min.css">
    <!--[if IE 7]><link rel="stylesheet" href="<%=path%>/static/css/font/font-awesome-ie7.min.css"><![endif]-->
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/core.css">
    <link rel="stylesheet" href="<%=path %>/static/css/examMng/examMng.css">
    <!--bootstrap基础引用 start-->
	<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/bootstrap.min.js"></script>
	<!--bootstrap基础引用 end-->
	<!--bootstrap-dialog start-->
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
	<script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
	<!--bootstrap-dialog end-->
    <script src="<%=path %>/static/js/respond.js"></script>


    <!--[if !IE]> -->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path %>/static/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
    </script>
    <!-- <![endif]-->

</head>
<body>
<jsp:include page="../head.jsp" flush="true"/>
<!--body begin-->
<div class="main-container">
    <div class="container body-box">
        <div class="row content-box" style="margin:0;">
            <c:forEach items="${depList }" var="deps">
                <div class="col-lg-3 col-md-3 content-border">
                    <a href="javascript:doPost('<%=basePath %>depository/toKnows', ${deps.id })">
                        <img style="height: 249px;" src="<%=basePath %>${deps.picture }">
                        <p class="title text-center">${deps.name }</p>
                        <a href="#" onclick="del(${deps.id});" style="padding: 0px 0px;" data-toggle="modal">
                            <div id="delBtn4" class="del" style="top:14px;right: 12px;">
                            </div>
                        </a>
                    </a>
                </div>
            </c:forEach>
            <div class="col-lg-3 col-md-3 content-border">
                <a href="<%=basePath %>depository/toAddPage">
                    <img style="height: 249px;" src="<%=path %>/static/images/examMng/toggle-expand-alt.png">
                    <p class="title text-center">新增题库</p>
                </a>
            </div>
        </div>
    </div>
</div>
<!--body end-->
<script>
    $(function () {
        // $('#topMain').children().eq(4).addClass('active'); // 追加样式;
        // $('#topMain').children().eq(4).children().attr('href', '#');

        //试卷管理主页面
        if (${role eq 'master'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else if (${role eq 'trainee'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else {
            $('#topMain').children().eq(3).addClass('active'); // 追加样式;
            $('#topMain').children().eq(3).children().attr('href', '#');
        }


    })
    var nums = 0;
    $(document).ready(function () {
        nums = $(".main-container .info-add").length;
        footer_position();
        //当浏览器窗口大小改变时，设置显示内容的高度
        $(window).resize(function () {
            footer_position();
        });
    });

    function footer_position() {
        var winHeight = $(window).height();
        var myHeight = winHeight - 60 - 82 - 20;
        //alert(myHeight+"-"+$(".main").height());
        if ($(".main-container").height() <= myHeight) {
            $(".kw-footer").css("position", "fixed");
            $(".kw-footer").css("bottom", "0");
            $(".main-container").css("min-height", myHeight + "px");
        } else {
            $(".kw-footer").css("position", "initial");
        }
    }

    function del(depId) {
    	BootstrapDialog.confirm({
			title : '提示',
			message : '确定要删除此题库吗',
			size : BootstrapDialog.SIZE_SMALL,
			type : BootstrapDialog.TYPE_DEFAULT,
			closable : true,
			btnCancelLabel : '取消',
			btnOKLabel : '确定',
			callback:function(result){
				if(result){
					 $.ajax({
			                type: "POST",
			                url: "<%=basePath %>depository/delDep",
			                data: {"depId": depId},
			                success: function (data) {
			                	BootstrapDialog.confirm({
			        				title : '提示',
			        				message : data.msg,
			        				size : BootstrapDialog.SIZE_SMALL,
			        				type : BootstrapDialog.TYPE_DEFAULT,
			        				closable : true,
			        				btnCancelLabel : '取消',
			        				btnOKLabel : '确定',
			        				callback:function(result){
			        					 if (data.status == 1) {
						                        window.location.reload();
						                    }
			        				}
			        			});
			                }
			            })
				}
			}
		});
    }

    function doPost(to, p) {  // to:提交动作（action）,p:参数
        var myForm = document.createElement("form");
        myForm.method = "post";
        myForm.action = to;
        var myInput = document.createElement("input");
        myInput.setAttribute("name", "depId");  // 为input对象设置name
        myInput.setAttribute("value", p);  // 为input对象设置value
        myForm.appendChild(myInput);
        document.body.appendChild(myForm);
        myForm.submit();
        document.body.removeChild(myForm);  // 提交后移除创建的form
    }
</script>
</body>
</html>
